﻿using System;
using System.IO;

namespace TabSaver.ToolbarButtons
{
    /// <summary>
    /// This is a sample for toolbar button acting as COMObject.
    /// It'll appear in the tools menu of the ie and has specific behaviour 
    /// which can be influenced by setting different properties
    /// especially the AssociatedCLSIDExtension which is the guid of the target COMObject to launch
    /// </summary>
    public class SaveTabsObjectButton : SpicIE.Controls.ToolbarButton
    {
        /// <summary>
        /// The PluginGuid _must_ be a unique GUID to identify and register the COM object correctly
        /// </summary>
        public override string PluginGuid
        {
            get { return "9EB51D9F-5938-4e8e-ADB4-0BAF594D4B29"; }
        }

        /// <summary>
        /// The PluginProgID _must_ be provided to identify and register the COM object correctly
        /// </summary>
        public override string PluginProgID
        {
            get { return "TabSaver.SaveTabsObjectButton"; }
        }

        public SaveTabsObjectButton()
        {
            this.ButtonName = "Quick Save open Tabs";
            this.ButtonText = "Quick Save open Tabs";
            this.MenuText = "Quick Save open Tabs";
            this.MenuStatusBar = "Quick Save all Tabs that are opened in the current window";
            this.ButtonAppearance = ButtonAppearanceEnum.COMObject;

            // GetActivePath() represents the current directory where the plugin is located (and the ressources should be, too)
            // with HotIconPath you set the colored, active icon for the toolbar button
            // with Iconpath you set the grayscaled, inactive icon  for the toolbar button
            this.HotIconPath = Path.Combine(SpicIE.Host.GetActivePath() + Path.DirectorySeparatorChar + "Resources", "Save.ico");
            this.IconPath = Path.Combine(SpicIE.Host.GetActivePath() + Path.DirectorySeparatorChar + "Resources", "Save.ico");

            this.ButtomCustomMenu = ButtonCustomEnum.Tools;

            // here you specify the CLSID of the COM object you want to invoke
            // the COM object which shall be invoke, needs to implement the IOleCommandTarget interface
            // in this case the SimpleCOMObject is referenced here, to demonstrate this functionality
            this.AssociatedCLSIDExtension = new Guid("87EBBA22-E898-4743-A2A8-08D760A087F9");
        }
    }
}